package com.glodon.paas.framework.registry.core.type;

import com.glodon.paas.framework.registry.core.status.ServiceStatus;
import org.apache.zookeeper.data.Stat;

import java.util.Date;
import java.util.List;

/**
 * @author Don Li
 */
public final class ServiceDetail {
    private String id;
    private ServiceStatus status;
    private Date upTime;
    private int numInstances;
    private int numAvailableInstances;
    private List<ClientDetail> clients;

    public ServiceDetail(ServiceBasic basic, Stat stat) {
        id = basic.getId();
        upTime = new Date(stat.getCtime());
        numInstances = stat.getNumChildren();
        status = basic.getStatus();
        numAvailableInstances = basic.getAvailableInstances();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public ServiceStatus getStatus() {
        return status;
    }

    public void setStatus(ServiceStatus status) {
        this.status = status;
    }

    public Date getUpTime() {
        return upTime;
    }

    public void setUpTime(Date upTime) {
        this.upTime = upTime;
    }

    public int getNumAvailableInstances() {
        return numAvailableInstances;
    }

    public void setNumAvailableInstances(int numAvailableInstances) {
        this.numAvailableInstances = numAvailableInstances;
    }

    public int getNumInstances() {
        return numInstances;
    }

    public void setNumInstances(int numInstances) {
        this.numInstances = numInstances;
    }

    public List<ClientDetail> getClients() {
        return clients;
    }

    public void setClients(List<ClientDetail> clients) {
        this.clients = clients;
    }
}
